<template>
    <div class="jobcommon EditResumeInfo">
        <div class="smalbox">
            <div class="backnavjob">
                <h1 @click="closejibenxinxi('close')">
                    <img
                        data-v-61dd7a3d=""
                        src="../../assets//newimg/index/icon_right_h.png"
                        alt=""
                    />
                </h1>
                <h2>
                    <span>简历-语言能力</span>
                </h2>
                <h3></h3>
            </div>

            <div class="imSelectParent" @click="yuzhongKey = !yuzhongKey">
                <div class="list_height plist-txt imitateSelect">
                    <div class="pic"></div>
                    <div class="tit font14">
                        选择语种<span class="font_red_light">*</span>
                    </div>
                    <div class="describe font13">
                        <span class="selectTxt">{{ info.language_cn }}</span>
                    </div>
                    <div class="arrow"></div>
                    <div class="clear"></div>
                </div>
            </div>
            <div class="imSelectParent" @click="shuxiKey = !shuxiKey">
                <div class="list_height plist-txt imitateSelect">
                    <div class="pic"></div>
                    <div class="tit font14">
                        熟悉程度<span class="font_red_light">*</span>
                    </div>
                    <div class="describe font13">
                        <span class="selectTxt">{{ info.level_cn }}</span>
                    </div>
                    <div class="arrow"></div>
                    <div class="clear"></div>
                </div>
            </div>

            <div class="j_newbutton">
                <div class="j_newbtn" @click="closejibenxinxi()">保存</div>
            </div>

            <!-- 语种选择 -->
            <van-action-sheet
                v-model="yuzhongKey"
                :actions="yuzhongactions"
                @select="yuzhongSelect"
                :duration="0.2"
            />
            <!-- 熟练程度 -->
            <van-action-sheet
                v-model="shuxiKey"
                :actions="shuxiactions"
                @select="shuxiSelect"
                :duration="0.2"
            />
            <div class="zhanwei"></div>
        </div>
    </div>
</template>

<script>
import { axiosPost } from '../../axios';
import { Toast } from 'vant';
export default {
    name: '',
    props: ['language_level', 'language', 'dataProps'],
    data() {
        return {
            // 语种选择
            yuzhongKey: false,
            yuzhongactions: [],
            // 熟悉程度
            shuxiKey: false,
            shuxiactions: [],

            info: {
                id: '',
                language: '',
                language_cn: '',
                level: '',
                level_cn: '',
                pid: '',
            },
        };
    },
    computed: {},
    mounted() {
        // 设置传递过来的数据
        if (this.dataProps) {
            this.info = this.dataProps;
        }

        // 语种数据加工
        let language = [];
        for (let i in this.language) {
            language.push({
                name: this.language[i],
                id: i,
            });
        }
        this.yuzhongactions = language;

        // 熟悉程度
        let language_level = [];
        for (let i in this.language_level) {
            language_level.push({
                name: this.language_level[i],
                id: i,
            });
        }
        this.shuxiactions = language_level;
    },
    methods: {
        closejibenxinxi(type) {
            if (type) {
                this.$emit('closeProps', { type: 8, key: false });
                return;
            }
            if (!this.info.language_cn) {
                return Toast({
                    message: '请选择语种',
                    duration: 2000,
                });
            }
            if (!this.info.level_cn) {
                return Toast({
                    message: '请选择熟悉程度',
                    duration: 2000,
                });
            }
            axiosPost('/apis/resume/edit_lang', this.info, (res) => {
                Toast({
                    message: res.msg,
                    duration: 2000,
                });
                if (res.status != 1) {
                    return;
                }
                this.$emit('closeProps', { type: 8, key: true });
            });
        },
        // 语种选择
        yuzhongSelect(item) {
            this.yuzhongKey = false;
            this.info.language_cn = item.name;
            this.info.language = item.id;
        },
        // 熟悉程度
        shuxiSelect(item) {
            this.shuxiKey = false;
            this.info.level_cn = item.name;
            this.info.level = item.id;
        },
    },
};
</script>
<style lang="less" src="../../assets/css/jobCommon.less" scope></style>
<style lang="less" scope></style>
